<?php

use think\facade\Route;
use thans\jwt\middleware\JWTAuthAndRefresh;
use think\middleware\Throttle;

//全局路由变量
Route::pattern([
    'id'    => '\d+',
]);

Route::group(function (){
    Route::post('auth/login', 'Auth@wxLogin');
    // 显示模块控制
    Route::get('module/control', 'Module@control');
    // 自动刷新jwt
    Route::group(function (){
        Route::get('auth/me', 'Auth@me');
        Route::delete('auth/logout', 'Auth@logout');
        // 纪念日相关
        Route::get('anniversaries', 'Anniversary@index');
        Route::get('anniversary/latest', 'Anniversary@latestAnniversaries');
        Route::get('anniversary/show', 'Anniversary@show');
        Route::post('anniversary/add', 'Anniversary@store');
        Route::put('anniversary/update', 'Anniversary@update');
        Route::delete('anniversary/delete', 'Anniversary@del');
        // 虚拟对象
        Route::get('dummy', 'Dummy@show');
        Route::post('dummy', 'Dummy@store');
        Route::put('dummy', 'Dummy@update');
        // 恋爱随笔
        Route::get('jotting/list', 'DummyJotting@fetch');
        Route::post('jotting/create', 'DummyJotting@store');
        Route::get('jotting/:id/show', 'DummyJotting@show');
        Route::delete('jotting/:id/delete', 'DummyJotting@delete');
        // 恋爱日记
        Route::get('diary/list', 'LoveDiary@fetch');
        Route::post('diary/create', 'LoveDiary@create');
        Route::get('diary/:id/show', 'LoveDiary@show');
        Route::put('diary/:id/update', 'LoveDiary@update');
        Route::delete('diary/:id/delete', 'LoveDiary@delete');
        Route::get('diary/count/month', 'LoveDiary@countByMonth');
        Route::get('diary/label/list', 'LoveDiaryLabel@fetch');
        // 恋爱问题
        Route::get('love/questions', 'LoveQuestion@index');
        Route::get('love/question/:id', 'LoveQuestion@show');
        Route::post('love/question/:id/answer', 'LoveQuestion@answer');
        // 签到相关
        Route::post('sign/daily', 'UserSign@dailySign');    // 每日签到
        Route::get('sign/today/status', 'UserSign@todaySignStatus');    // 每日签到状态
        Route::get('sign/month/status', 'UserSign@queryMothSignData');    // 每月签到状态
        Route::get('sign/days/continue', 'UserSign@continueSignDays');    // 连续签到天数
        Route::post('sign/kiss', 'UserSign@kiss');    // 亲一亲
        Route::post('sign/hug', 'UserSign@hug');    // 抱一抱
        // 手机号
        Route::post('sms/send', 'Sms@sendSms'); // 发送手机号短信
        // 用户相关
        Route::put('user/mobile', 'User@modifyPhone'); // 修改用户手机号
        Route::put('user/info', 'User@modifyUserInfo'); // 修改用户手机号
        Route::get('user/statistics', 'User@statistics');   // 用户数据统计：恋人绑定时间，天数，互想天数等
        // 用户恋人
        Route::get('user/lover/bind/token', 'UserLover@getLoverBindToken');  // 获取邀请token
        Route::post('user/lover/bind', 'UserLover@bindLoverByToken');    // 通过邀请token绑定
        Route::post('user/lover/unbind', 'UserLover@unbindLover');   // 解绑恋人
        Route::get('user/love/score', 'LoveScore@getUserLoveScore');    //用户恩爱值
        // 钱包相关
        Route::get('user/wallet/info', 'UserWallet@walletInfo');    // 钱包信息
        Route::get('user/wallet/logs', 'UserWallet@walletLogs');    // 钱包日志
        Route::post('user/wallet/withdraw', 'UserWallet@withdraw'); // 发起提现
        Route::get('user/wallet/withdraw/list', 'UserWallet@userWithdrawList'); // 提现列表
        Route::get('user/wallet/withdraw/status', 'UserWallet@lastWithdrawStatus'); // 最近一条提现状态
        // 上传功能
        Route::post('upload/image', 'Upload@image');    // 单图上传
        Route::post('upload/temp', 'Upload@uploadTemp');    // 上传文件到临时文件夹
        // 成就奖励
        Route::get('achieve/list', 'LoveAchieve@queryAchieve');
        Route::post('achieve/:id/accept', 'LoveAchieve@acceptAchieveReward');
        // 排行榜
        Route::get('rank/top100', 'LoveScore@top100');
        Route::get('rank/self', 'LoveScore@selfRank');
        Route::post('rank/bless', 'LoveScore@sendBless');
        // 支付相关
        Route::post('pay/miniprogram', 'Pay@miniprogram');   // 小程序支付
        Route::get('pay/status', 'Pay@queryPayStatus');   // 小程序支付
        Route::get('pay/status', 'Pay@queryPayStatus');   // 小程序支付
        Route::post('Activity/loveWallet', 'Activity@loveWallet');   // 恋爱钱包接口
    })->middleware([
        JWTAuthAndRefresh::class,
        \app\weapp\middlewares\CheckJwt::class,
    ]);
    // 微信相关
    Route::post('decrypt/phone', 'Wechat@decryptPhone');
    Route::get('share/qrcode', 'Wechat@generateShareQRCode');
})->prefix('\app\xiangji\controller\\')->middleware([Throttle::class]);

Route::any('pay/notify/wechat', '\app\xiangji\controller\Pay@wxPayNotify');   // 微信支付回调
